package com.giscloud.redis.config;

import com.giscloud.redis.utils.RedisUtils;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.script.RedisScript;

/**
 * @Classname GiscloudRedisConfiguration
 * @Description 配置信息实体类
 * @Date 2020/5/29 17:56
 * @Created by gis
 */
@Configuration
@Log4j2
public class GiscloudRedisConfiguration {
    @Autowired
    private CustomRedisTemplate<String,Object> rTemplate;
    @Autowired
    private CustomRedisTemplate<String,String> sTemplate;
    @Autowired
    private RedisScript<Long> rateLimiterClientLua;

    @Bean(name = "redisUtils")
    public RedisUtils redisUtils() {
        log.debug("start to initialize RedisUtils");
        return new RedisUtils(rTemplate,sTemplate,rateLimiterClientLua);
    }
}
